'use strict';
const base = require('./base');
const moment = require('moment');
module.exports = app => {
  const { STRING, DATE } = app.Sequelize;

  const Warranty = app.model.define('warranty',
    Object.assign(base(app), {
      num: { type: STRING, primaryKey: true, },
      equip_num: STRING(64),
      name: STRING(64),
      error: STRING(64),
      equip_status: STRING(32),
      status: STRING(32),
      position: STRING(32),
      report_name: STRING(64),
      // report_time: {
      //   type: DATE,
      //   defaultValue: () => {
      //     return moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
      //   },
      //   get() {
      //     return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
      //   },
      // },
    }));
  Warranty.associate = () => {
    Warranty.belongsTo(app.model.Sys.User, {
      foreignKey: 'created_id',
      // targetKey:'created_id'
    })
  };
  return Warranty;
};
